﻿//using System;
//using System.Collections.Generic;
//using NthDownload.Contracts.Plugins.Downloads;
//using NthDownload.Contracts;
//using System.Threading.Tasks;
//using System.IO;

//namespace NthDownload.DownloadPlugins.LocalDownload
//{
//    public class LocalDownloadUIService : IDownloadUIService
//    {
//        private readonly IDownloadFactory _factory;

//        public LocalDownloadUIService(IDownloadFactory factory)
//        {
//            _factory = factory;
//        }

//        public Task<List<IDownload>> ShowAddDownloads()
//        {
//            List<IDownload> downloads = new List<IDownload>();
//            TaskCompletionSource<List<IDownload>> createTaskCompletionSource = new TaskCompletionSource<List<IDownload>>();

//            //
//            // Prompt for Source folder
//            //
//            System.Windows.Forms.FolderBrowserDialog dlgSource = new System.Windows.Forms.FolderBrowserDialog();
//            if (dlgSource.ShowDialog() != System.Windows.Forms.DialogResult.OK)
//            {
//                createTaskCompletionSource.SetResult(downloads);
//                return createTaskCompletionSource.Task;
//            }

//            DirectoryInfo diSource = new DirectoryInfo(dlgSource.SelectedPath);

//            if (!diSource.Exists)
//            {
//                createTaskCompletionSource.SetResult(downloads);
//                return createTaskCompletionSource.Task;
//            }

//            //
//            // Prompt for Destination folder
//            //
//            System.Windows.Forms.FolderBrowserDialog dlgDest = new System.Windows.Forms.FolderBrowserDialog();
//            if (dlgDest.ShowDialog() != System.Windows.Forms.DialogResult.OK)
//            {
//                createTaskCompletionSource.SetResult(downloads);
//                return createTaskCompletionSource.Task;
//            }

//            DirectoryInfo diDest = new DirectoryInfo(dlgDest.SelectedPath);

//            if (!diDest.Exists)
//            {
//                createTaskCompletionSource.SetResult(downloads);
//                return createTaskCompletionSource.Task;
//            }

//            //
//            // Create downloads for all files in the source folder
//            //
//            Task task = new Task(() =>
//            {
//                foreach (FileInfo fi in diSource.EnumerateFiles())
//                {
//                    downloads.Add(_factory.CreateDownload(fi.FullName, diDest.FullName));
//                }

//                createTaskCompletionSource.SetResult(downloads);
//            });

//            task.Start();

//            return createTaskCompletionSource.Task;
//        }

//        public Task<IDownload> ShowEditDownload(IDownload download)
//        {
//            throw new NotImplementedException();
//        }

//        public void ShowSettings()
//        {
//        }
//    }
//}
